from datetime import datetime

from django.db import models
from  django.contrib.auth.models import AbstractUser
# Create your models here.
class User(models.Model):
    mobile=models.CharField(max_length=11,verbose_name='手机号')
    username = models.CharField(max_length=30,verbose_name='用户名')
    password = models.CharField(max_length=256,verbose_name='密码')
    avatar= models.CharField(max_length=256,default='',verbose_name='头像')
    sex=models.IntegerField(default=0,verbose_name='性别：0：男，1：女')
    create_time = models.DateTimeField(verbose_name='注册时间',default=datetime.now)
    last_login = models.DateTimeField(verbose_name='最后登录时间',default=datetime.now,)
    class Meta:
        db_table='user'
        verbose_name_plural='用户表'
    def __str__(self):
        return self.username
class Addr(models.Model):
    receiver=models.CharField(max_length=30,verbose_name='收货人')
    receive_mobile=models.CharField(max_length=11,verbose_name='手机号')
    receive_addr=models.CharField(max_length=100,verbose_name='收货地址')
    is_default=models.BooleanField(default=False,verbose_name='默认地址')
    user=models.ForeignKey(User,on_delete=models.CASCADE,verbose_name='用户')
    class Meta:
        db_table='addr_t'
        verbose_name_plural='收货地址表'
    def __str__(self):
        return self.receiver + " " + self.receive_mobile + " " + self.receive_addr
